<?php

namespace common\models\c2\entity;

use common\models\c2\statics\ProductType;
use kzo\base\components\events\LinkManyBehavior;
use kzo\base\models\statics\EntityModelStatus;
use kzo\user\models\BeUser;
use Yii;
use yii\behaviors\BlameableBehavior;
use yii\helpers\ArrayHelper;

/**
 * This is the model class for table "{{%product}}".
 *
 * @property string $id
 * @property integer $type
 * @property string $sku
 * @property string $name
 * @property string $label
 * @property string $factory_price
 * @property string $supplier_id
 * @property string $currency_id
 * @property string $measure_id
 * @property string $description
 * @property integer $sold_count
 * @property string $created_by
 * @property string $updated_by
 * @property integer $status
 * @property integer $position
 * @property string $created_at
 * @property string $updated_at
 */
class Assemble extends Product
{

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['type', 'supplier_id', 'currency_id', 'measure_id', 'sold_count', 'created_by', 'updated_by', 'status', 'position'], 'integer'],
            [['name',], 'required'],
            [['factory_price'], 'number'],
            [['description'], 'string'],
            [['name', 'sku'], 'unique'],
            [['created_at', 'updated_at'], 'safe'],
            [['sku', 'name', 'label'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app.c2', 'ID'),
            'type' => Yii::t('app.c2', 'Type'),
            'sku' => Yii::t('app.c2', 'Sku'),
            'name' => Yii::t('app.c2', 'Name'),
            'label' => Yii::t('app.c2', 'Label'),
            'factory_price' => Yii::t('app.c2', 'Factory Price'),
            'supplier_id' => Yii::t('app.c2', 'Supplier ID'),
            'currency_id' => Yii::t('app.c2', 'Currency ID'),
            'measure_id' => Yii::t('app.c2', 'Measure ID'),
            'description' => Yii::t('app.c2', 'Description'),
            'sold_count' => Yii::t('app.c2', 'Sold Count'),
            'created_by' => Yii::t('app.c2', 'Created By'),
            'updated_by' => Yii::t('app.c2', 'Updated By'),
            'status' => Yii::t('app.c2', 'Status'),
            'position' => Yii::t('app.c2', 'Position'),
            'created_at' => Yii::t('app.c2', 'Created At'),
            'updated_at' => Yii::t('app.c2', 'Updated At'),
        ];
    }

    /**
     * setup default values
     **/
    public function loadDefaultValues($skipIfSet = true)
    {
        parent::loadDefaultValues($skipIfSet);
        $this->type = ProductType::TYPE_ASSEMBLE;
    }

}
